<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%> 
<script type="text/javascript">
	var ruleManager={
		filepath:"",
		basepath:"",
		uploadError:function(msg) {
			Ext.Msg.alert("Message", msg);
		},
		uploade:function(d){
			var record = Ext.getCmp("f_grid").getSelectionModel().getSelected();
			if(record){
				if(d.indexOf("success")==0){
				    var i = F_store.f_store.find("front",d.substr(6),0,true,true);//匹配store中的路径,已有不再新增
					if(i==-1){
						Ext.Ajax.request({
							url: "paper!updPaperInfo.action",
							params: {
								"paperInfo.id": record.data.id,
								"paperInfo.bg_no": record.data.bg_no,
								"paperInfo.front":d.substr(7)
							},
							success: function(res){
								F_store.f_store.load({params:{"paperCC.paper_no": record.data.id}});
							}
						});
					}
					Ext.Msg.show({
			   			title:"提示",
			   			msg:"操作成功!",
			   			buttons:Ext.Msg.OK,
			   			icon: Ext.MessageBox.INFO
					});
				}
				else if(d.indexOf("exists")==0){
					Ext.Msg.show({
			   			title:"提示",
			   			msg:"文件已存在,请重新选择上传的文件!",
			   			buttons:Ext.Msg.OK,
			   			icon: Ext.MessageBox.ERROR
					});
				}
			}
		},
		validate : function(){
			var record = Ext.getCmp("f_grid").getSelectionModel().getSelected();
			//验证是否选中
			if(record){
				return true;
			}else{
				Ext.Msg.show({
					title:"警告",
					msg: "请选择上传的底板信息!",
					buttons: Ext.Msg.OK,
					animEl: "elId",
					icon:Ext.MessageBox.WARNING
				});
				return false;
			}
		}
	};
	//预印纸从表数据源
	var F_store = {
		f_store : new Ext.data.JsonStore({
			root: "data",
			idProperty: "bg_no",
			fields: ["id", "bg_no", "bg_name", "befor_type","front"],
			url: "paper!paperInfoList.action"
		})
	};

	var prod_opera;//传给ajax url属性的action字符串
	var opt=false;//增加规则按钮操作标示
	
	/*********************************************************************/
	//预印纸数据源
	var store = new Ext.data.JsonStore({
		root: "data",
	   	totalProperty: "total",
	   	fields : [ "pid","paper_no","paper_name","paper_weight",
	   	   	"person_no","create_time","period_begin","period_end","period_day","businpnt_name","businpnt_no"],
		url : "paper!GridList.action"
	});

	//卡产品关联的外包商数据源
	var b_store = new Ext.data.JsonStore({
		root: "data",
       	totalProperty: "total",
		fields: ["id", "name", "linkman", "linkphone","linkaddr", "state",
				"ftp", "port", "ftpuser", "ftppass", "ftppath", "remark"],
       	url: "epiboly!condiList.action"
	});
	/*********************************************************************/
	var p1 = {
		id : "p1",
		xtype: "grid",
		stripeRows:true,
		loadMask : true,//在加载数据时遮罩住元素,替换元素Updater的加载提示器，并且在初始化加载之后销毁
		autoExpandColumn:"paper_name",//自动填充
		autoExpandMin : 100,//自动填充最小宽度
		headersDisabled: true,
		store : store,
		columns : [new Ext.grid.RowNumberer({header: "序号", width: 35}),
			        {dataIndex : "pid",			header : "序列号", menuDisabled: true},
			        {dataIndex : "paper_no",	header : "预印纸编号",menuDisabled: true},
			        {dataIndex : "businpnt_name",	header : "外包商",menuDisabled: true},
			        {dataIndex : "paper_name",	header : "名称",id:"paper_name",menuDisabled: true},      
			        {dataIndex : "paper_weight",header : "克重",menuDisabled: true},
			        {dataIndex : "period_begin",header : "有效开始月",menuDisabled: true},
			        {dataIndex : "period_end",	header : "有效截止月",menuDisabled: true},
			        {dataIndex : "period_day",	header : "账单日",menuDisabled: true},
			        {dataIndex : "person_no",	header : "创建人",menuDisabled: true},
			        {dataIndex : "create_time",	header : "创建时间",menuDisabled: true}],
		bbar: new Ext.ux.PagingToolbar( {
			pageSize : limit,
			store : store
		}),
		buttonAlign : "center",
		buttons : [
				{
					text : "新增",
					handler : function() {
						prod_opera = "paper!addPaper.action";
						var panel = this.ownerCt.ownerCt.ownerCt;
						var node=Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode();//当前选中的树节点
						if(node && node.isLeaf()){
							Ext.Ajax.request({
								url: "paper!nextKey.action",
								success: function(response, opts){
									var d=eval("("+response.responseText+")");
									if(d.code == "0"){
										F_store.f_store.removeAll();
										var rootnode = Ext.getCmp("cityspanel").getRootNode();
										rootnode.removeAll();
										Ext.getCmp("areaform").resetParam(node.id,d.data);
										panel.layout.setActiveItem(1);
									} else {
										Ext.Msg.show({
		   									title:"提示",
		   									msg:"操作失败!",
		   									buttons:Ext.Msg.OK,
		   									icon: Ext.MessageBox.ERROR
										});
									}
								}
							});
						}else{
						    Ext.Msg.show({
		   						title:"警告",
		   						msg: "没有选中任何行节点，无法进行此操作!",
		   						buttons: Ext.Msg.OK,
		   						animEl: "elId",
		   						icon:Ext.MessageBox.WARNING
							});
						}
					}
				},{
					text : "修改",
					handler : function() {
						prod_opera = "paper!updPaper.action";
						var record = Ext.getCmp("p1").getSelectionModel().getSelected();
						var node=Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode();//当前选中的树节点
						if (record) {
								Ext.getCmp("rule_panel").layout.setActiveItem(1);
								Ext.getCmp("areaform").setParam(record.data);
								Ext.Ajax.request({
									url: "treeCheck!cardCity1.action",
									params: {
										"paperCityCrd.card_no": Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode().id,
										"paperCityCrd.paper_no": Ext.getCmp("pid").getValue(),
										"paperCityCrd.businpnt_no": Ext.getCmp("businpnt_no").getValue()
									},
									success: function(res){
										var rootnode = Ext.getCmp("cityspanel").getRootNode();
										rootnode.removeAll();
										rootnode.appendChild(eval("("+res.responseText+")"));
									}
								});
								//加载从表数据
								F_store.f_store.load({params:{"paperCC.paper_no": record.data.pid}});
						} else {
							Ext.Msg.show({
		   						title:"警告",
		   						msg: "请先选择一条记录，然后点击修改!",
		   						buttons: Ext.Msg.OK,
		   						animEl: "elId",
		   						icon:Ext.MessageBox.WARNING
							});
						}
					}
				},
				{
					text : "删除",
					handler : function() {
						prod_opera = "paper!delPaper.action";
						var p1 = this.ownerCt.ownerCt;
						var record = p1.getSelectionModel().getSelected();
						if (record) {
							Ext.Msg.confirm("警告","确定要删除吗?", function(btn){
							    if (btn == "yes"){
							    	Ext.Ajax.request( {
							    		url : prod_opera,
							    		params : {
							    			"paperCC.paper_no":record.data.pid,
							    			"paperCC.card_no":Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode().id,
							    			"paperCC.businpnt_no":record.data.businpnt_no
							    		},
							    		success: function(response, opts){
											var d=eval("("+response.responseText+")");
											if(d.code == "0"){
												Ext.getCmp("p1").getBottomToolbar().doRefresh();
												Ext.Msg.show({
	   												title:"提示",
	   												msg:"操作成功!",
	   												buttons:Ext.Msg.OK,
	   												icon: Ext.MessageBox.INFO
												});
											} else {
												Ext.Msg.show({
	   												title:"提示",
	   												msg:"操作失败!",
	  												buttons:Ext.Msg.OK,
	   												icon: Ext.MessageBox.ERROR
												});
											}
										}
							    	});
							    }
							});									
						} else {
							Ext.Msg.show({
		   						title:"警告",
		   						msg: "请先选择一条记录，然后点击删除!",
		   						buttons: Ext.Msg.OK,
		   						animEl: "elId",
		   						icon:Ext.MessageBox.WARNING
							});
						}
					}
				}]
	};

	var org_add_update = 0;
    
	var p2 = {
		id:"areaform",
		region: "north",
		height:250,
		columnWidth: 1,
		xtype :"form",
		title:"预印纸信息",
		bodyStyle : "padding:5px 5px 0",
		defaultType : "textfield",
		items : [
		{	id: "pid",
			fieldLabel : "序列号",
			anchor:"100%",
			disabled: true,
			name : "pid"
		},{	id:"paper_no",
			fieldLabel : "预印纸编号",
			maxLength:30,
			anchor:"100%",
			name : "paper_no",
			validator:function (val){
				if(val=="")return "该输入项为必填项！";
				try {
					if (!/\W/.test(val))
						return true;
					Ext.getCmp("paper_no").setValue("");
					return "请输入英文字母,数字其它字符是不允许的！";
				} catch (e) {
					Ext.getCmp("paper_no").setValue("");
					return "请输入英文字母,数字其它字符是不允许的！";
				}
			},
			listeners: {
				'blur': function(){
					var paper_no = Ext.getCmp("paper_no").getValue();
					if(paper_no.length != 0){
						Ext.Ajax.request({
							url: "paper!checkPaperNo.action",
							params: {
								"paperCC.paper_no": paper_no
							},
							success: function(response){
								var d=eval("("+response.responseText+")");
								if(d.code == "1"){
									Ext.getCmp("paper_no").setValue("");
									Ext.Msg.show({
			   							title:"提示",
			   							msg:"该编号已存在，请重新输入！",
			   							buttons:Ext.Msg.OK,
			   							icon: Ext.MessageBox.ERROR
									});
								}
							}
						});
					}
				}
			}
		},{	id: "paper_name",
			fieldLabel : "预印纸名称",
			vtype:"alphanumchinese",
			validator:function (val){
        		if(val=="")return "该输入项为必填项！";
        		if(Ext.fucCheckCHLength(val)>50){
        			return "请输入50个字符范围内的值！<br>注：一个中文字符算两个字符的长度！";
        		}
        		return true;
        	},
			anchor:"100%",
			name : "paper_name"
		},{	id:"businpnt_no",
			fieldLabel:"外包商",
			name :"businpnt_no",
			xtype:"billCombox",
			store: b_store,
			valueField: "id",
			displayField: "name",
			listeners: {
				"select": function(){
					businpnt_no =this.value;
					Ext.Ajax.request({
						url: "treeCheck!cardCity1.action",
						params: {
							"paperCityCrd.card_no": Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode().id,
							"paperCityCrd.paper_no": Ext.getCmp("pid").getValue(),
							"paperCityCrd.businpnt_no": businpnt_no
						},
						success: function(res){
							var rootnode = Ext.getCmp("cityspanel").getRootNode();
							rootnode.removeAll();
							rootnode.appendChild(eval("("+res.responseText+")"));
						}
					});
				}
			}
		},{	id: "paper_weight",
			fieldLabel: "克重",
			xtype:"numberfield",
			maxValue: 100,
			name: "paper_weight",
			anchor: "100%",
			validator: function(val){
				if(val==""){return "该输入项为必填项！";}
				if(!(/^[\d]{1,3}$/).test(val) || val==0){
					return "该项必须为非零正整数，且不大于100！";
					}
				return true;
			}
		},{	id: "person_no",
			name: "person_no",
			fieldLabel: "人员编号",
			hidden: true
		},{	id: "create_time",
			name: "create_time",
			fieldLabel: "创建时间",
			hidden: true
		},{
			id : "period_begin",
			fieldLabel : "有效开始月",
			anchor:"100%",
			vtype: "daterange",
       		endDateField: "period_end",
			name : "period_begin",
			xtype:"datefield",format:"Y-m",editable :false,
			validator: function(val){
				if(val==""){return "该输入项为必填项！";}
				return true;
			}
		},{
			id : "period_end",
			fieldLabel : "账期截止月",
			anchor:"100%",
			vtype: "daterange",
       		startDateField: "period_begin",
			name : "period_end",
			xtype:"datefield",format:"Y-m",editable :false,
			validator: function(val){
				if(val==""){return "该输入项为必填项！";}
				return true;
			}
		},{
			id : "period_day",
			fieldLabel : "账单日",
			anchor: "100%",
			name : "period_day",
			xtype: "billCombox", 
			store: sys_store.stmtdate,
			validator: function(val){
				if(val==""){return "该输入项为必填项！";}
				return true;
			}
		}],
		setParam : function(data) {
			Ext.getCmp("pid").setValue(data.pid);
			Ext.getCmp("paper_no").setDisabled(true);
			Ext.getCmp("paper_no").setValue(data.paper_no);
			Ext.getCmp("businpnt_no").setValue(data.businpnt_no);
			Ext.getCmp("businpnt_no").setDisabled(true);
			Ext.getCmp("paper_name").setValue(data.paper_name);
			Ext.getCmp("paper_weight").setValue(data.paper_weight);
			Ext.getCmp("period_begin").setValue(data.period_begin);
			Ext.getCmp("period_end").setValue(data.period_end);
			Ext.getCmp("period_day").setRawValue(data.period_day);
		},
		resetParam : function(cardno,id) {
			Ext.getCmp("pid").setValue(id);
			Ext.getCmp("paper_no").setValue("");
			Ext.getCmp("paper_no").setDisabled(false);
			Ext.getCmp("businpnt_no").setValue("");
			Ext.getCmp("businpnt_no").setDisabled(false);
			Ext.getCmp("paper_name").setValue("");
			Ext.getCmp("paper_weight").setValue("");
			Ext.getCmp("period_begin").setValue("");
			Ext.getCmp("period_end").setValue("");
			Ext.getCmp("period_day").setRawValue("");
		}
	};
	
	var personrule = new Ext.grid.GridPanel({
        store: F_store.f_store,
        id:"f_grid",
        title: "底板信息",
        stripeRows : true,
        selModel : new Ext.grid.RowSelectionModel(),//设置为行选择器
        region: "center",
        tbar:[{
				text:"增加",
				xtype:"button",
				handler:function(){
					if(Ext.getCmp("paper_no").getValue().length == 0){
						Ext.Msg.show({
		   					title:"警告",
		   					msg: "请先输入预印纸编号!",
		   					buttons: Ext.Msg.OK,
		   					animEl: "elId",
		   					icon:Ext.MessageBox.WARNING
						});
						return false;
					}
					//获取待插入底板的编号
					var i = 1;
					for(; i < 8; i+=2){
						if(i > 6) {
						Ext.Msg.show({
		   					title:"警告",
		   					msg: "底板添加数量已超过最大数，请先删除!",
		   					buttons: Ext.Msg.OK,
		   					animEl: "elId",
		   					icon:Ext.MessageBox.WARNING
							});
							return false;
						}
						if(F_store.f_store.find("bg_no",i) == -1) {
							break;
						}
					}
	                Ext.Ajax.request({
						clientValidation: true,
						params: {
							"paperInfo.bg_no": i,
							"paperInfo.bg_name":Ext.getCmp("paper_no").getValue(),
							"paperInfo.id":Ext.getCmp("pid").getValue()
						},
						url: "paper!addPaperInfo.action",
						success: function(response, opts){
							var d=eval("("+response.responseText+")");
							if(d.code == "0"){
								F_store.f_store.load({params:{"paperCC.paper_no": Ext.getCmp("pid").getValue()}});
							} else {
								Ext.Msg.show({
		   							title:"提示",
		   							msg:"操作失败!",
		   							buttons:Ext.Msg.OK,
		   							icon: Ext.MessageBox.ERROR
								});
							}
						}
					});
				}
			},{
				text:"删除",
				xtype:"button",
				handler:function(){
						var record = personrule.getSelectionModel().getSelected();
						if (record) {
							Ext.Msg.confirm("警告","确定要删除吗?", function(btn){
							    if (btn == "yes"){
							    	Ext.Ajax.request( {
							    		url : "paper!delPaperInfo.action",
							    		params : {
							    			"paperInfo.id":record.data.id,
							    			"paperInfo.bg_no":record.data.bg_no
							    		},
							    		success: function(response, opts){
											var d=eval("("+response.responseText+")");
											if(d.code == "0"){
												F_store.f_store.load({params:{"paperCC.paper_no": Ext.getCmp("pid").getValue()}});
													Ext.Msg.show({
		   												title:"提示",
		   												msg:"操作成功!",
		   												buttons:Ext.Msg.OK,
		   												icon: Ext.MessageBox.INFO
													});
											} else {
												Ext.Msg.show({
		   											title:"提示",
		   											msg:"操作失败!",
		   											buttons:Ext.Msg.OK,
		   											icon: Ext.MessageBox.ERROR
												});
											}
										}
							    	});
							    }
							});									
						} else {
							Ext.Msg.show({
		   						title:"警告",
		   						msg: "请先选择一条记录，然后点击删除!",
		   						buttons: Ext.Msg.OK,
		   						animEl: "elId",
		   						icon:Ext.MessageBox.WARNING
							});
						}
					}
			},"->",{
		           	 xtype:"flash",
		           	 id:"flashupload",
		           	 anchor:"anchor",
		           	 expressInstall:true,//如果没有安装flash，提示用户进行安装
		           	 width:70,
		           	 height:22,
		           	 url:"flash/upload.swf",
		           	 flashParams:{
		           	 	quality:"high",
		           	 	allowScriptAccess:"sameDomain",
		           	 	allowFullScreen:true
		           	 },
		           	 flashVars:{
						requestUrl:"upload.action",
						type:"paper",
						fileFilterName:"Images (*.jpg)",
						fileFilterValue:"*.jpg",
						error : encodeURI(ruleManager.uploadError),
						complete:encodeURI(ruleManager.uploade),
						validate:encodeURI(ruleManager.validate)
					 }
			}],
        columns:[
        	{header: "底板编号",	dataIndex:"bg_no"},
			{header: "底板名称",	dataIndex:"bg_name"},
			{header: "类型", 	dataIndex:"befor_type"
				,renderer:function(value){
					if(value == 1) return "正";
					else if(value == 2) return "反";
				}},
			{header: "上传状态",	dataIndex:"front"	
				,renderer:function(value){
					if(null != value) return "已上传";
					else return "待上传";
				}
			},
			{	xtype:"actioncolumn",
    			header: "预览",
    			width:34,
    			items:[{
			    icon:"images/shared/icons/fam/information.png",  // Use a URL in the icon config
                tooltip:"预览",
                handler: function(grid, rowIndex, colIndex) {
					var rec = F_store.f_store.getAt(rowIndex);
					var win=Ext.getCmp("showimages");
					win.show();
					var html="<img id='imgpage' width="+win.getInnerWidth()+" height="+win.getInnerHeight()+" src='download.action?id="+encodeURI(rec.get('front'))+"&time="+encodeURI(new Date().getTime())+"' />";
					win.update(html);
					return false;
                 }
             }]
			}
		],
		listeners:{
			"click":function(){
				var record = personrule.getSelectionModel().getSelected();
				if(record){
					ruleManager.filepath=ruleManager.basepath+record.data.bg_name+".jpg";
					getFlashObject("flashupload").addID(ruleManager.filepath);
				}
		}}
    });

    var rulePanel2 = {
    	xtype:"billTreePanel",
    	region: "east",
    	border:true,
    	split:false,
    	width: 200,
	    id:"cityspanel",
		autoScroll:true,
		title:"城市预印纸设置",
		rootVisible:false,
		root:{
			id:"root"
		}
    };
    
	var p3=new Ext.Panel({
		id:"view3",
		layout:"border",
		border:false,
		autoScroll: true,
		items:[p2,{
			region: "center",
			xtype: "panel",
			id:"rulePanl",
			layout:"border",
			border:false,
			items: [personrule,rulePanel2]
		}],
		buttonAlign : "center",
		buttons : [{
			text : "保存",
			id:"save",
			handler : function(e) {
				Ext.getCmp("cityspanel").root.expandChildNodes();
				var t_citys = Ext.getCmp("cityspanel").getChecked();
				var citys = "";
				for(var i = 0; i < t_citys.length; i++) {
					if(t_citys[i].isLeaf())
						citys += "|" + t_citys[i].attributes.id;
				}
				citys = citys.substring(1);
				if(null == citys || "" == citys) {
					Ext.Msg.show({
		   				title:"警告",
		   				msg: "必须选择关联城市!",
		   				buttons: Ext.Msg.OK,
		   				animEl: "elId",
		   				icon:Ext.MessageBox.WARNING
					});	
					return false;
				}
				if(!Ext.getCmp("areaform").getForm().isValid()){
					Ext.Msg.show({
		   				title:"提示",
		   				msg:"验证不通过!",
		   				buttons:Ext.Msg.OK,
		   				icon: Ext.MessageBox.ERROR
						});
					return;
				}
				var obj = this;
				e.setDisabled(true);
				Ext.Ajax.request({
					clientValidation: true,
					params: {
						"paperCC.city_no": citys,
						"paper.pid":Ext.getCmp("pid").getValue(),
						"paper.paper_no":Ext.getCmp("paper_no").getValue(),
						"paper.paper_name":Ext.getCmp("paper_name").getValue(),
						"paper.paper_weight":Ext.getCmp("paper_weight").getValue(),
						"paper.person_no":Ext.getCmp("person_no").getValue(),
						"paper.create_time":Ext.getCmp("create_time").getValue(),
						"paper.period_begin":Ext.getCmp("period_begin").getValue(),
						"paper.period_end":Ext.getCmp("period_end").getValue(),
						"paper.period_day":Ext.getCmp("period_day").getRawValue(),
						"paperCC.card_no":Ext.getCmp("prod_tree").getSelectionModel().getSelectedNode().id,
						"paperCC.businpnt_no":Ext.getCmp("businpnt_no").getValue()
					},
					url: prod_opera,
					success: function(response, opts){
						var d=eval("("+response.responseText+")");
						if(d.code == "0"){
							Ext.getCmp("p1").getBottomToolbar().doRefresh();
							Ext.Msg.show({
	   							title:"提示",
	  							msg:"操作成功!",
	   							buttons:Ext.Msg.OK,
	   							icon: Ext.MessageBox.INFO
							});
							Ext.getCmp("rule_panel").layout.setActiveItem(0);
						} else {
							Ext.Msg.show({
		  						title:"提示",
		   						msg:"操作失败!",
		   						buttons:Ext.Msg.OK,
		   						icon: Ext.MessageBox.ERROR
							});
						}
						Ext.getCmp("save").setDisabled(false);
					}
				});
		  }
		  
		},{
			text : "取消",
			handler : function(){
				if(prod_opera=="paper!addPaper.action" && F_store.f_store.data.length!=0) {
					Ext.Msg.confirm("警告","已成功添加底板信息，是否取消添加预印纸?<br>确定将删除已添加底板信息！", function(btn){
					    if(btn == "no") {
					    	return false;
					    } else {
					    	Ext.Ajax.request( {
					    		url : "paper!delPaperInfoById.action",
					    		params : {
					    			"paper.pid": Ext.getCmp("pid").getValue()
					    		}
					    	});
					    	Ext.getCmp("rule_panel").layout.setActiveItem(0);
				    	}
					});
				} else {
					Ext.getCmp("rule_panel").layout.setActiveItem(0);
				}
			}
		}]
	});

	//获取文件上传路径
	var query = function(node){
		if(node.parentNode.id == "root") {
			return 	node.id;
		} else if(node.isLeaf()) {
			return query(node.parentNode)+"/PREVIEW/"+node.id+"/";
		}
		return query(node.parentNode);
	};
	
	var paper_pel = new Ext.Panel( {
		border : false, 
		layout : "border",
		items:[{
			id:"prod_tree",
			xtype : "billTreePanel",
			dataUrl : "tree!product.action",
			root : new Ext.tree.AsyncTreeNode( {
				id : "root",
				expanded : true
			// 自动展开节点
			}),
			listeners : {
				"click"	: function(node) {
				    if(node.isLeaf()){
				    	store.baseParams = store.baseParams || {};
				    	store.baseParams["paperCC.card_no"] = node.id;
				    	store.load({params:{start : 0,limit : limit}});
						b_store.load({params:{"paperCC.card_no": node.id}});
						ruleManager.basepath=query(node);
						Ext.getCmp("rule_panel").layout.setActiveItem(0);
				    }
				}
			}
		}, {
			region: "center",
			id:"rule_panel",
			border : false, 
			layout:"card",
			activeItem:0,//显示第一个容器
			items: [p1, p3]
		} ]
	});
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(paper_pel);
	CenterPanel.doLayout();


</script>